package com.zcrain.aspectjdemo;

import android.util.Log;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

/**
 * @Author:CWQ
 * @DATE:2023/12/6
 * @DESC:
 */

@Aspect
public class MyAspectJ {
    private static final String TAG = "MyAspectJ";

    @Before("execution(* android.app.Activity+.onDestroy(..))")
    public void beforeAll(JoinPoint joinPoint) {
        Log.d(TAG, "beforeAll: " + joinPoint.getSignature().getName());
    }

    @After("execution(* android.app.Activity+.onCreate(..))")
    public void afterAll(JoinPoint joinPoint) {
        Log.d(TAG, "afterAll: " + joinPoint.getSignature().getName());
    }

    @Around("execution(* android.app.Activity+.onStart(..))")
    public void aroundAll(ProceedingJoinPoint joinPoint) throws Throwable {
        Log.d(TAG, "aroundAll before: " + joinPoint.getSignature().getName());
        joinPoint.proceed();
        Log.d(TAG, "aroundAll after:" + joinPoint.getSignature().getName());
    }
}